package top.likeqc.leetcode.editor.cn;

/**
 * @see <a href="https://leetcode.cn/problems/strong-password-checker-ii">leetcode题库</a>
 */
public class StrongPasswordCheckerIi {
    public static void main(String[] args) {
        Solution solution = new StrongPasswordCheckerIi().new Solution();
        System.out.println(solution.strongPasswordCheckerII("-Aa1a1a1"));

        System.out.println("IloveLe3tcode!".matches(".*[a-z]+.*"));
    }
    // leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean strongPasswordCheckerII(String password) {
            if (password.length() < 8) {
                return false;
            }
            if (!password.matches(".*[a-z]+.*")) {
                return false;
            }
            if (!password.matches(".*[A-Z]+.*")) {
                return false;
            }
            if (!password.matches(".*[0-9]+.*")) {
                return false;
            }
            if (!password.matches(".*[!@#$%^&*()\\-+]+.*")) {
                return false;
            }
            for (int i = 1; i < password.length() - 1; i++) {
                if (password.charAt(i - 1) == password.charAt(i)) {
                    return false;
                }
            }

            return true;
        }
    }
    // leetcode submit region end(Prohibit modification and deletion)

}
